$(function (){

    $(".inforTitle .step em:eq(1)").css("background", "rgb(255, 48, 48)");
    $(".inforTitle .step em:eq(2)").css("background", "rgb(255, 48, 48)");
    $(".inforTitle .schedule i:eq(0)").css("border-top-color", "rgb(255, 48, 48)");
    $(".inforTitle .schedule i:eq(1)").css("border-top-color", "rgb(255, 48, 48)");

    $(".inforGet button").click(function (realAuthCode) {

        if($(".inforMail input").val() !== ""){
            let phone = $(".inforMail input").val();
            if(localStorage.getItem("currentLoginUserPhone.aomall.com") === phone){
                // 手机号码校验成功
                $.ajax({
                    url: "/xiumiPhone.do",
                    type: "post",
                    dataType: "json",
                    data: {
                        "info" : localStorage.getItem("currentLoginUserPhone.aomall.com"),
                        "phone" : phone
                    },
                    success: function (data_json) {
                        if(data_json.status === "true"){
                            // 验证码发送成功，将验证码存到本地缓存
                            localStorage.setItem("xiumiAuthCode.comall.com", data_json.authCode);
                            console.log(data_json.authCode);
                            $("#sendMailMSG").html(data_json.message);
                        }else{
                            // 验证码发送失败
                            $("#sendMailMSG").html(data_json.message);
                        }
                    }
                })
            }else{
                $("#sendMailMSG").html("请输入正确的手机号码！");
                console.log("请输入正确的手机号码");
            }
        }
    })

    $(".inforSubmit button").click(function () {

        if($(".inforMail input").val() === ""){
            $("#sendMailMSG").html("请输入手机号码");
        }else if($(".inforYzm input").val() === ""){
            $("#sendMailMSG").html("请输入验证码");
        }else{
            let authCode = $(".inforYzm input").val();
            let realAuthCode = localStorage.getItem("xiumiAuthCode.comall.com");
            if(realAuthCode === authCode){
                // 验证码识别正确
                window.location.href = "/WebContent/member/Member-xiumiInput.html";
            }else{
                // 验证码识别失败
                alert("验证码错误，请核对无误后输入");
            }
        }
    })
})